
matrix beta = e(b)
matrix vcv = e(V)

local min_time = 1
local max_time = 11
local Base = 6
local Time "refitime"

** Set enviornment for coefficient data
clear
set obs `=`max_time' - `min_time' + 1'

gen `Time' = `min_time' + _n - 1

foreach x in  coeff se ci_min ci_max {
	gen `x' = .
}


** Create data used for the plot
local rownum = 0
foreach t of numlist `min_time'/`max_time' {	
	quietly {
	if `t' ~= `Base' {
		local n = colnumb(beta, "`t'.`Time'") // get the columns index for this particular variable
		
		replace coeff = beta[1,`n'] if `Time' == `t'
		local se = sqrt(vcv[`n',`n']) 
		replace ci_min = coeff + invt(`e(df_r)',0.025)*`se' if `Time' == `t'
		replace ci_max = coeff + invt(`e(df_r)',0.975)*`se' if `Time' == `t'
	}
	if `t' == `Base' {
		foreach x in coeff se ci_min ci_max {
			replace `x' = 0 if `Time' == `t'
		}
	}
	}
}
replace `Time' = `Time' - 6

qui su `Time'
local min_time = `r(min)'
local max_time = `r(max)'



** Set enviornment for pictures

local plotopt scheme(s2mono) xlabel(-5 0 5) /* xlabel(-11 -6 0 6 12) */ ///
	ylabel(`ylabel', angle(0)) ///
	graphregion(color(gs16) ilc(gs16)) plotregion(lc(gs0)) ///
	xtitle("black")	legend(off) 



** Plot the coefficients
format coeff* %13.4fc


twoway rarea ci_min ci_max `Time', astyle(ci) || /// 
	function y = 0, range(`min_time' `max_time') lpattern(solid) lcolor(gs8) || ///
	scatter coeff* `Time' , xline(0, lpattern(dash)) connect(l) lcolor(black)  mstyle(p1) mcolor(none) || ///
	`AddXline' || ///
	scatter coeff* `Time' if `Time' < 0 , msymbol(X) mstyle(p1)  msize(large)  mcolor(black) mlabpos(6) || ///
	scatter coeff* `Time' if `Time' >= 0 , mstyle(p1) mcolor(black) mlabpos(12) || ///
	, `plotopt' `fig_title' `unit' `ylabel' xtitle("")
